package com.socialuni.center.web.user.login;

import com.socialuni.center.web.model.RO.CenterLoginRO;
import com.socialuni.center.web.model.RO.user.CenterMineUserDetailRO;
import com.socialuni.sdk.domain.SocialUserDODomainCreate;
import com.socialuni.sdk.model.DO.user.UserDO;
import com.socialuni.sdk.model.ProviderLoginQO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class CenterProviderLoginDomain {
    @Resource
    private SocialUserDODomainCreate socialUserDODomainCreate;
    @Resource
    private CenterLoginEntity centerLoginEntity;

    public CenterLoginRO<CenterMineUserDetailRO> providerLogin(ProviderLoginQO loginQO) {
        //创建或返回
        UserDO mineUser = socialUserDODomainCreate.getOrCreate(loginQO);
        //根据user获取返回结果
        CenterLoginRO<CenterMineUserDetailRO> userDetailROUniLoginRO = centerLoginEntity.centerLogin(mineUser);

        return userDetailROUniLoginRO;
    }

}
